package com.example.pokemon_integrado;

import com.Manager.SceneManager;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class MainActivity extends Activity implements Runnable{
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.i("", "on create");
		
		Thread thread = new Thread(this);
		thread.start();
		
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);

	    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		
		View view = new MainCode(this, null);
		setContentView(view);	
	} 
	
	public void onBackPressed() 
	{
	    SceneManager.getInstance().getBack(true);
	}
	
	@Override
	public void run() 
	{
		while (true) {
			try {
				Thread.sleep((long)1);
			} catch (InterruptedException e) {
				Log.e("", "interrupcao do run()");
			}

			if(SceneManager.getInstance().currentScene == 2){
				startActivity(new Intent(MainActivity.this, LoginActivity.class));
				break;
			}
			if(SceneManager.getInstance().currentScene == 6)
				finish();
		}
	}
}
